Grading Guidelines For Homework

Homework solutions will be graded on the following criteria:

All code should be written individually by the student, unless otherwise specified in the HW. Students are encouraged to work together, but sharing code is a violation of academic integrity.



HW 6 Due Thurs Nov 5th by 10pm

File format: .ipynb notebook file submitted to Notebowl. Each solution should be contained in a seperate, individual code cell. Clearly label each solution with a Markdown cell. Docstrings are required for all functions. No (English language) discussion/explanation is required, although any discussion you provide about your solution (contained in a Markdwown cell) may help you earn partial credit.

Students have choice for this HW:

Pick two of the following three problems:

In addition, pick two of the following four problems:

A student’s maximum score will be the sum of two problems from one list, two from the other. If more than two from either list is submitted, their grade will be the lowest two scores in the lists.



HW 5 Due Thurs Oct 22 by 10pm

File format: .ipynb notebook file on Notebowl. Each solution should be contained in one code cell, discussion for each in an accompanying Markdown cell.

Book Problems:

HW 4 Due Thurs Oct 8 by 5pm

File Format: turn in an .ipynp notebook file to NoteBowl. The name should be lastname_firstname_hw4.ipynb. For example:

hopper_grace_hw4.ipynp

Your notebook should be neatly formatted, with a heading (including your name, the assignment, the class, the date) and appropriate use of Markdown cells alongside code cells.

The Model: Mortgage Payments

Time for some modelling, y’all!


Uh, I meant mathematical models!


Buying a house is the biggest financial decision most Americans (or humans of any nationality) will make. In order to finance the purchase, most folks will need to take out a loan. Loans for property are called “mortgages”. These loans use an interest schedule known as “amortization”:

  • a: to/onto/upon
  • mort: death
  • ize: to make

Thus “amortization” literally means “to make it dead”, or “to kill it off”. Isn’t that nice?

The mechanics of amortized amortized loans are quite simple, but the choices that buyers make can have dramatic implications for the total amount of money they spend (and also the time it takes to pay the loan). For context, most Americans choose a 30-year amortization schedule – that’s most of your working life!

In this HW, you’ll write a computer model to investigate these considerations. First, let’s establish some terminology:

  • The closing price is the amount of money that the property sells for. It’s called that because the process of finalizing a mortgage is called “closing”.
  • The down payment is the amount of money that the property buyers pay immediately upon purchase. In this way, buyers pay a portion of the total closing price immediately upon purchase, and the rest is payed on a loan schedule.
  • The principal is the amount of money that property buyers need to borrow in order to buy the property. Upon purchase, the principal is easy to calculate:

    principal = closing price - down payment

    In other words, this is the debt that home buyers have to begin with upon purchasing their property.

    Each month, the principal gets smaller as owners pay off the debt.

  • The APR, or Annual Percentage Rate, is the interest rate that homeowners are charged for their loan. Generally this rate is somewhere between 2% - 6%. Important Note Interest is added to the loan on a monthly basis. See details right below.

  • The interest is the finance charge added to the balance. It’s based on the APR. Each month, the interest is calculated by the following model:

    interest = principal*apr/12

  • The payment is the amount that buyers pay each month for their loan. Each month, the payment will first pay off the interest accrued, and the remainder will go to the principal.

    Thus, each month, the principal is decreased by the following formula:

    principal = principal - (payment - interest)

Deliverables (Ie, What Ya Gotta Do)

Students must write a script, in one code cell at the beginning of the notebook, that includes the following functions:

  • monthlyPayment() [arguments up to you] should take as input the current principal, payment, and apr. It should return as output a list of the following:
    • the new principal,
    • the amount of interest paid that month, and
    • how much of the payment went to principal (ie payment - interest)
  • paymentHistory() [arguments up to you] should take as input the closing price, the down payment, the apr, and the monthly payments. This function should use a loop to calculate the balance each month for the duration of the loan (until the balance is zero) using the monthlyPayment() function. It should return as output a list of the following:
    • a list of the balances for each month (starting at the original principal and decreasing to zero)
    • a list of the interest charges each month
    • a list of the amounts for each month of money spent on principal.
  • printRecords() [argument up to you] should take as input the results of your paymentHistory() function, and print the following on a row-by-row (ie month-by-month) basis to the console:
    • The year and month of the loan
    • The current balance for that month
    • The principal paid that month
    • The interest paid that month
    The results should be neatly, thoughtfully formatted using a format string as discussed in class and the text. Here’s example output for a home that with a closing price of $165,000, a down payment of $30,000, an APR of 3.25%, and a monthly payment of $950:
  • plotTotals() should take as input the results of your paymentHistory() function, and use the matplotlib library to plot the following monthly TOTALS:
    • Total principal paid each month
    • Total interest paid each month
    • Balance remaining each month
    Here’s an example using the same input as the table above:
  • main() should control the action as usual. Your main() function should prompt the user for the following input:
    • closing price
    • down payment
    • apr
    • monthly payments
    • It should also ask the user whether they’d like a table or a plot. Depending on user choice, printRecords or plotTotals functions should be called.

All functions must have an accompanying docstring explaining their purpose, the inputs, and the outputs.

For partial credit, use comments to exlain what your code does.

Short-Answer Reflection

Below your code for the above model, use additional code cells to actually run the model you wrote above. In particular, you should experiment with:

  • Different choices of down payment
  • Different choices of apr
  • Different choices of payment

Using Markdown cells, discuss:

  • What conclusions do you draw from these investigations?
  • What advice do you have for property buyers? Of course debt is bad, that’s not the point. What strategies would you suggest for a young adult getting started who wants to buy a home?

Be creative. Play around with your model. Have fun!

Closing Remarks

As usual, the assignment description lays out the minimum qualifications. You don’t have to get it 100% right to pass, you just need to show me your thoughts and ideas. Your code must actually run in order to earn a passing grade, but know that I’ll give you partial credit for making it part of the way to the complete assignment.

To earn an A, students must implement all functionality as described above, in good clear style with documentation.

You may find opportunities to improve upon the output and structure of the program. Be sure your work satisfies the minimum requirements, but feel free to expand upon these and to exercise your creativity. I enjoy reading your work, and maybe there’s a stoic nod from Prof Miller in your future. ;D

HW 3 Due Friday 9/25 by 5pm

File Format: turn in a .py script file to NoteBowl. The name should be lastname_firstname_hw3.py. For example:

lovelace_ada_hw3.py

This HW will focus on the turtle library discussed in class. The goal of the program is to allow the user to create shape patterns based on their input.

Your script should contain the following functions:

Grading:

HW 2 Due Friday 9/11 by 5pm

File Format: turn in the .ipynb file for your notebook. Name it with this format:

Lastname_Firstname_HW3.ipynb

So, if I was a student, I’d turn in:

Miller_Alice_HW3.ipynb

Problems:

  1. 2.2.7
  2. 2.2.8
  3. 2.3.4

  4. In class on Friday Sept 04, we wrote a for loop to assign each employee in a list of employees a day of the week to work on.

[['Ali, Fred'], ['Ben', 'Greg'], ['Charles', 'Helen'], ['Deb', 'Ian'], ['Ellie', 'Jack']]

HW 1 Due Friday 8/28 by 5pm

File format: Problems should be completed in a Jupyter Labs notebook, exported to html (we’ll talk about this in class). The .html file should be submitted to NoteBowl under the HW 1 assignment.

Each solution should be written in a separate Markdown cell, showing the problem number with a header (you can make a header by starting the line with “#”).

The first cell of the notebook should have a header for the title of the assignment (CS 111 HW 1), and your name.

The problems for this HW come from the text:

All of these problems should be solved in clear, concise English sentences (or lists). No code here.